<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/_mozilla/bluetooth/bluetooth-helpers.js"></script>
<script>
'use strict';

let test_specs = [{
    filters: [{ namePrefix: ''}]
}, {
    filters: [{ namePrefix: '', name: 'Name'}]
}, {
    filters: [{ namePrefix: '', services: [heart_rate.name]}]
}, {
    filters: [{ namePrefix: '', name: 'Name', services: [heart_rate.name]}]
}, {
    filters: [{ namePrefix: ''}],
    optionalServices: [heart_rate.name]
}, {
    filters: [{ namePrefix: '', name: 'Name'}],
    optionalServices: [heart_rate.name]
}, {
    filters: [{ namePrefix: '', services: [heart_rate.name]}],
    optionalServices: [heart_rate.name]
}, {
    filters: [{ namePrefix: '', name: 'Name', services: [heart_rate.name]}],
    optionalServices: [heart_rate.name]
}];

promise_test(t => {
    window.testRunner.setBluetoothMockDataSet(adapter_type.empty);
    let promises = [];
    test_specs.forEach(args => {
        promises.push(promise_rejects_js(t, TypeError, window.navigator.bluetooth.requestDevice(args)));
    });
    return Promise.all(promises);
}, 'requestDevice with empty namePrefix. Should reject with TypeError.');
</script>
